<div class="panel">
    <form action="{:U('Product/inventory_edit_save')}" method="post">
        <table class="table-form">
            <tr>
                <th>商品名称：</th><td>{$data.productName}
            </td></tr>
            <tr>
                <th>系统库存：</th><td>{$data.stock}<input type="hidden" name="oldStock" value="{$data.stock}" />
            </td></tr>
            <tr>
                <th>盘点库存：</th><td>
                <input type="text" name="stock" placeholder="盘点库存" size="8" required/>
            </td></tr>
            <tr>
                <th>数量差额：</th><td>
                <input type="text" name="number" readonly="readonly" size="8" /> (输入盘点库存后自动计算)
            </td></tr>
            <tr>
                <th>盘点备注：</th><td>
                <input type="text" name="remark" size="33" placeholder="盘点备注" />
            </td></tr>
            <tr>
                <th class="col-idx"><a href="#" class="btn-arrowstop lnk-multiple" onclick="">&nbsp;</a></th><td>                
            <if condition="$upr['盘点调仓']"><button type="submit">保存</button></if><button type="reset">重置</button>
            </td></tr>
        </table>
        <input type='hidden' name='id' value='{$data.id}'/>
    </form>
</div>
<script>
    $('input[name="stock"]').blur(function () {
        var old = $('input[name="oldStock"]').val();
        var stock = $(this).val();
        if (!stock) {
            alert('库存数量无效!');
            return;
        }
        $('input[name="number"]').val(stock - old);
    });
</script>